package com.legend.ddz;

import com.legend.ddz.util.CustomAssetsManage;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.Bitmap.Config;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

/**
 * 
 * @author zhugh
 * @date 2012-7-19 下午9:49:29
 * @description TODO
 * 
 */

public class SimpleGraphics extends Activity
{
	CustomAssetsManage assetsManage;
	Bitmap dizhuBitmap;
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		MyView view = new MyView(this);
		//设置无标题
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		//设置全屏
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(view);
		assetsManage = new CustomAssetsManage(this);
		dizhuBitmap = assetsManage.readAssetsSource("dizhu.png");
	}

	private class MyView extends View
	{
		private Paint paint = new Paint();
		private Context context; 

		public MyView(Context context)
		{
			super(context);
			this.context = context; 
		}

		@Override
		protected void onDraw(Canvas canvas)
		{
			super.onDraw(canvas); 
			canvas.drawBitmap(initialize(), 0, 0, paint);
			canvas.drawBitmap(dizhuBitmap, 50, 50, paint);
			Rect rect = new Rect();
			//rect.set(left, top, right, bottom); 
		} 
		
		//获得和屏幕一样大小的图片
		private Bitmap initialize()
		{
			DisplayMetrics dm = getResources().getDisplayMetrics();
			int mScreenWidth = dm.widthPixels;// 屏幕宽
			int mScreenHeight = dm.heightPixels;// 屏幕高 
			//Bitmap bmp = ((BitmapDrawable) getResources().getDrawable(R.drawable.icon)).getBitmap();// 源图片
			Bitmap bmp = assetsManage.readAssetsSource("background_start.png");
			Bitmap mBitmap = Bitmap.createScaledBitmap(bmp, mScreenWidth, mScreenHeight, true); // 按指定大小转换
			return mBitmap;
		}
	}

}
